isEmpty = function(obj) {
    for (var prop in obj) {
        if (obj.hasOwnProperty(prop)) return false;
    }
    return true;
}; (function($) {
    $.cookie = function(key, value, options) {
        if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
            options = $.extend({},
                options);
            if (value === null || value === undefined) {
                options.expires = -1;
            }
            if (typeof options.expires === 'number') {
                var days = options.expires,
                    t = options.expires = new Date();
                t.setDate(t.getDate() + days);
            }
            value = String(value);
            return (document.cookie = [encodeURIComponent(key), '=', options.raw ? value: encodeURIComponent(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', options.path ? '; path=' + options.path: '', options.domain ? '; domain=' + options.domain: '', options.secure ? '; secure': ''].join(''));
        }
        options = value || {};
        var decode = options.raw ?
            function(s) {
                return s;
            }: decodeURIComponent;
        var pairs = document.cookie.split('; ');
        for (var i = 0,
                 pair; pair = pairs[i] && pairs[i].split('='); i++) {
            if (decode(pair[0]) === key) return decode(pair[1] || '');
        }
        return null;
    };
})(jQuery);
function toUsersPosition(val) {
    return getTranslation('mmm_extra_admin_user_position_' + val);
}
function toLocalStorage(key, data) {
    localStorage.setItem(key, JSON.stringify(data));
}
function fromLocalStorage(key) {
    return JSON.parse(localStorage.getItem(key));
}
function checkUserPermission(module, right) {
    if (right) {
        return (user_perms[module] && (user_perms[module]['all'] || user_perms[module][right]));
    } else {
        return typeof(user_perms[module] != 'undefined') ? user_perms[module] : false;
    }
}
var selectedUserId = null;
function log(m) {
    if (window.console) {} else {
        alert(m);
    }
}
var pic_server="https://mmmplus.co/fileupload/pic/Upload?times=";
var user_settings=[];
var need_to_update_cookie = '';
var need_to_update_timeout = false;
function toCookie(name, index, val) {
    return $.Deferred(function(def) {
        if (!user_settings[name] || !user_settings[name][index] || user_settings[name][index] != val) {
            if (need_to_update_timeout) clearTimeout(need_to_update_timeout);
            if (!user_settings[name]) user_settings[name] = [];
            user_settings[name][index] = val;
            need_to_update_cookie += '&' + name + '[' + index + ']=' + val;
            need_to_update_timeout = setTimeout(function() {
                    if (need_to_update_cookie.length > 0) {
                        need_to_update_cookie = '';
                        def.resolve(true);
                    }
                },
                1000);
        } else {
            def.resolve(true);
        }
    }).promise();
}
function fromCookie(name, index) {
    return typeof(user_settings) != 'undefined' ? (user_settings[name] && user_settings[name][index] ? user_settings[name][index] : '') : '';
}
function goodParseInt(val) {
    return parseInt(val, 10);
}
function rusDate(dt) {
    var m = dt.getMonth();
    m++;
    if (m < 10) {
        m = '0' + m;
    }
    var d = dt.getDate();
    if (d < 10) {
        d = '0' + d;
    }
    return d + '.' + m + '.' + dt.getFullYear();
}
function showAlert(text) {
    var call = false;
    var type = 'error';
    if (arguments.length > 1) {
        call = arguments[2];
        type = arguments[1] || type;
    }
    if (!call) $.messager.alert(getTranslation('Warning'), getTranslation(text));
    else $.messager.alert(getTranslation('Warning'), getTranslation(text), type, call);
}
function showWarning(text) {
    showAlert(text, 'warning',
        function() {});
}
function showInfo(text) {
    var call = false;
    if (arguments.length > 1) {
        call = arguments[1];
    }
    if (!call) $.messager.alert(getTranslation('Info'), getTranslation(text), 'info');
    else $.messager.alert(getTranslation('Info'), getTranslation(text), 'info', call);
}
function showError(text) {
    var call = false;
    if (arguments.length > 1) {
        call = arguments[1];
    }
    if (!call) $.messager.alert(getTranslation('Error'), getTranslation(text), 'error');
    else $.messager.alert(getTranslation('Error'), getTranslation(text), 'error', call);
}
function showConfirm(text, f) {
    $.messager.confirm(getTranslation('Confirm'), getTranslation(text), f);
}
function showOk(text) {
    $.messager.show({
        'title': getTranslation('Ok'),
        'msg': getTranslation(text),
        'showType': 'fade',
        'timeout': 3000
    });
}
//
function getTranslation(text) {
    if (typeof text == 'undefined') return '';
    if (!text) {
        return '';
    }
    translation = lang_vars[text.trim()];
    if ((translation == 'null' || !translation) && typeof(lang_vars[text]) != 'undefined') translation = text;
    if (arguments.length > 1) {
        args = typeof(arguments[1]) === 'object' ? arguments[1] : Array.prototype.slice.call(arguments, 1);
        translation = format(translation ? translation: text, args);
    }
    return translation ? translation: text;
}
function handleState(data) {
    return data && data[8] == 0;
}
function readNotice(id) {
    if ($('.menu_notice_item_' + id).hasClass('read')) return false;
    $('.menu_notice_item_' + id).addClass('read');

    $.ajax({
        url: '59.npl?o=r',
        data: {
            i: id
        },
        success: function(data) {
            if (handleState(data)) {
                if (data[42] == 1) current_unread_notices--;
                $('#menu_notice .unread').html(current_unread_notices);
                setTimeout(function() {
                        $('.menu_notice_item_' + id).remove();
                    },
                    600);
            }
        }
    });
}
function gotoPage(pid) {
    window.location = 'pages.html#/pages/' + pid;
}
var current_unread_notices = 0;
var current_unread_last = 0;
var current_sent_timezone = 0;
function clickNotice() {}
function showNoticesSub() {
    $.ajax({
        url:baselocation+"/my_messages_happy/getNotice/",
        type: 'get',
        dataType: 'json',
        success:function(result){
            if(result.notices==null){
                return;
            }
            if(result.notices.length>0){
                var html = '<div class="menu_notice_item_15199882" onmouseover="$(this).addClass(\'notice-active\');" onmouseout="$(this).removeClass(\'notice-active\');">'
                $.each(result.notices, function(i, item) {

                    html=html+'<div><a href="#" class="easyui-menubutton" onclick="return false;" style="float:right;">[x]</a>'
                        +item.name+'<br>'+item.notice_time+item.notice_message+'</div>'

                });
                html=html+'</div>'
                $('#noticesSub').html(html).css({"width":"250px","left":"1075px","top":"30px","display":"block","height":"auto","overflow-y":"scroll","z-index":"10050000"});
                $('#noticesSub').show();
            }
        }
    });
}
function checkNotice() {
    if (typeof(no_59) != 'undefined' && no_59) {
        return true;
    }
    if (current_unread_notices && current_unread_notices >= 20) return false;
    var send = '';
    if (current_unread_last) {
        send = '&f=' + current_unread_last;
    } else if (!current_sent_timezone) {
        var jan = new Date(2012, 0, 1, 2, 0, 0);
        var jul = new Date(2012, 6, 1, 2, 0, 0);
        send += '&wtz=' + jan.getTimezoneOffset();
        send += '&stz=' + jul.getTimezoneOffset();
    }

}
function format(str, replacements) {
    if (typeof(str) != 'string') {
        return str;
    }
    if (typeof(replacements) !== 'object' && arguments.length > 2) {
        replacements = Array.prototype.slice.call(arguments, 1);
    }
    for (var i in replacements) {
        if (!replacements.hasOwnProperty(i)) {
            continue;
        }
        str = str.replace(new RegExp('\\{' + i + '\\}', 'g'), replacements[i]);
    }
    return str;
}
function number_format(number, decimals, dec_point, thousands_sep) {
    var i, j, kw, kd, km, minus = "";
    if (number < 0) {
        minus = "-";
        number = number * -1;
    }
    if (isNaN(decimals = Math.abs(decimals))) {
        decimals = 2;
    }
    if (dec_point == undefined) {
        dec_point = ",";
    }
    if (thousands_sep == undefined) {
        thousands_sep = ".";
    }
    i = parseInt(number = ( + number || 0).toFixed(decimals)) + "";
    if ((j = i.length) > 3) {
        j = j % 3;
    } else {
        j = 0;
    }
    km = (j ? i.substr(0, j) + thousands_sep: "");
    kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
    kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
    return minus + km + kw + kd;
}
function fBankCodeAutoC(call) {
    var b = this.val();
    var t = this;
    this.autocomplete('73.npl?a=ltb&u=' + selectedUserId, {
        delay: 10,
        minChars: 3,
        matchSubset: 1,
        autoFill: false,
        matchContains: 1,
        cacheLength: 10,
        selectFirst: false,
        formatItem: liFormat,
        maxItemsToShow: 10,
        onItemSelect: selectItem
    });
    if ([50, 30, 62].indexOf(parseInt(user_perms.id_country, 10)) < 0) {
        $d = $('<div style="clear: both; margin-left: 200px;"><a>' + getTranslation('emoney_descr') + '</a></div>');
        $d.appendTo($(this).parent().parent());
        $('a', $d).css('cursor', 'pointer').click(function() {
            $win = $('<div><div style="padding: 20px;">' + getTranslation('emoney_list') + '' + '<div style="text-align: center;"><a class="close">' + getTranslation('Ok') + '</a></div></div></div>');
            $('a.close', $win).linkbutton({
                iconCls: 'icon-ok'
            }).click(function() {
                $win.window('close');
            });
            $win.window({
                title: getTranslation('emoney_descr'),
                modal: true,
                closable: false,
                collapsible: false,
                close: function() {
                    $(this).window('destroy');
                }
            });
        });
    }
}
function fBankCodeAllC() {
    var b = this.val();
    var t = this;
    this.autocomplete('73.npl?a=ltb&u=0', {
        all: true,
        delay: 10,
        minChars: 3,
        matchSubset: 1,
        autoFill: false,
        matchContains: 1,
        cacheLength: 10,
        selectFirst: false,
        formatItem: liFormat,
        maxItemsToShow: 10,
        onItemSelect: selectItem
    });
}
function liFormat(row, i, num) {
    var result = '<span>' + row[0] + '</span> ' + row[1];
    return result;
}
function selectItem(li) {
    if (li == null) var sValue = '';
    if ( !! li.extra) var sValue = li.extra[2];
    else var sValue = li.selectValue;
    return li.extra[0];
    $input.vValidateBankCodeAll();
}
$.fn.vValidateBankCode = function() {
    var b = $(this).val();
    var t = this;
    $.ajax({
        url: '73.npl',
        data: {
            'a': 'tb',
            'b': b,
            'u': selectedUserId
        },
        success: function(data) {
            if (handleState(data)) {
                if (!data.b.id) {
                    $(t).addClass('wizard-invalid');
                    $(t).next().remove();
                    $(t).data('_error_message', getTranslation('Your bank not supported'));
                    $(t).trigger('change');
                } else {
                    $(t).removeClass('wizard-invalid');
                    $(t).data('_error_message', '');
                    $(t).next().remove();
                    var ad = '';
                    if (data.b.code != 'OTHERBANK') {
                        $(t).val(data.b.code);
                        if (data.b.descr.np) {
                            ad += data.b.descr.np + ', ';
                        }
                        if (data.b.descr.addr) {
                            ad += data.b.descr.addr;
                        }
                        if (ad) {
                            ad = '<strong>' + getTranslation('Address') + ':</strong> ' + ad + '<br/>';
                        }
                        $(t).after($('<div>' + '<strong>' + getTranslation('Bank name') + ':</strong> ' + data.b.name + '<br/>' + ad + '</div>'));
                        $(t).data('bank_name', data.b.name);
                    }
                    $(t).data('target_template', data.b.target_template);
                    $(t).trigger('change');
                }
            }
        },
        dataType: "json"
    });
}
$.fn.vValidateBankCodeAll = function() {
    var b = $(this).val();
    var t = this;
    $.ajax({
        url: '73.npl',
        data: {
            'a': 'tb',
            'b': b,
            'u': 0
        },
        success: function(data) {
            if (handleState(data)) {
                if (!data.b.id) {
                    $(t).addClass('wizard-invalid');
                    $(t).next().remove();
                    $(t).data('_error_message', getTranslation('Your bank not supported'));
                    $(t).trigger('change');
                } else {
                    $(t).removeClass('wizard-invalid');
                    $(t).data('_error_message', '');
                    $(t).next().remove();
                    var ad = '';
                    if (data.b.code != 'OTHERBANK') {
                        $(t).val(data.b.code);
                        if (data.b.descr.np) {
                            ad += data.b.descr.np + ', ';
                        }
                        if (data.b.descr.addr) {
                            ad += data.b.descr.addr;
                        }
                        if (ad) {
                            ad = '<strong>' + getTranslation('Address') + ':</strong> ' + ad + '<br/>';
                        }
                        $(t).after($('<div>' + '<strong>' + getTranslation('Bank name') + ':</strong> ' + data.b.name + '<br/>' + ad + '</div>'));
                        $(t).data('bank_name', data.b.name);
                    }
                    $(t).data('target_template', data.b.target_template);
                    $(t).trigger('change');
                }
            }
        },
        dataType: "json"
    });
}
function vValidateStNumber($this, $with) {
    if (!$with.val() && !$this.val()) {
        $this.addClass('wizard-invalid');
        $this.data('_error_message', getTranslation('You must one of two fields "Card Number" or "Account Number"'));
    } else {
        $this.data('_error_message', '');
        $this.removeClass('wizard-invalid');
    }
}
function findLiById(id, el) {
    var r = false;
    $(el).find('li').each(function() {
        if (typeof(this.qqFileId) != 'undefined' && this.qqFileId == id) {
            r = this;
        }
    });
    return r;
}
function createUploader(el, callbackComplite, callbackSubmit, allowedExtensions) {
    var uploader_data = {
        element: el,
        action: '200.npl?el=' + $(el).attr('name'),
        onComplete: function(id, fileName, rj) {
            var li = findLiById(id, el);
            $(li).find('.qq-upload-delete').fadeIn();
            if (rj.thumb) {
                $(li).find('.qq-upload-file').text(rj.sz.mime);
                $(li).find('.qq-upload-delete').click(function() {
                    $.ajax({
                        url: '200.npl',
                        data: {
                            a: 'do_d',
                            el: rj.el,
                            f: rj.sandbox_name
                        },
                        success: function() {
                            $(li).remove();
                        }
                    });
                });
                var i = new Image();
                i.onload = function() {
                    $('<img src="' + this.src + '" width="' + rj.thumb.w + '" height="' + rj.thumb.h + '" style="display: none;" /><br/>').prependTo($(li)).fadeIn();
                    $(li).find('img').attr('title', rj.filename);
                };
                i.src = rj.thumb.link;
            }
            if (typeof(callbackComplite) != 'undefined') {
                callbackComplite();
            }
        },
        onSubmit: function(id, fileName, rj) {
            if (typeof(callbackSubmit) != 'undefined') {
                callbackSubmit();
            }
        },
        debug: false
    };
    if (typeof(allowedExtensions) != 'undefined') {
        uploader_data.allowedExtensions = allowedExtensions;
    }

}
function createLoadingMessage() {
    $("<div class=\"loading_message_mask\"></div>").appendTo($(document.body));
    $("<div class=\"loading_message\"></div>").appendTo($(document.body));
}
function loadingShow() {
    $('.loading_message_mask').show();
    $('.loading_message').show();
}
function loadingHide() {
    $('.loading_message_mask').hide();
    $('.loading_message').hide();
}
function htmlspecialchars(text) {
    var chars = new Array("&", "<", ">", '"', "'");
    var replacements = new Array("&amp;", "&lt;", "&gt;", "&quot;", "'");
    for (var i = 0; i < chars.length; i++) {
        var re = new RegExp(chars[i], "gi");
        if (re.test(text)) {
            text = text.replace(re, replacements[i]);
        }
    }
    return text;
}
String.prototype.nl2br = function() {
    var br;
    if (typeof arguments[0] != 'undefined') {
        br = arguments[0];
    } else {
        br = '<br />';
    }
    return this.replace(/\r\n|\r|\n/g, br);
}
String.prototype.br2nl = function() {
    var nl;
    if (typeof arguments[0] != 'undefined') {
        nl = arguments[0];
    } else {
        nl = '\r\n';
    }
    return this.replace(/\<br(\s*\/|)\>/g, nl);
}
var sprintf = (function() {
    function get_type(variable) {
        return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
    }
    function str_repeat(input, multiplier) {
        for (var output = []; multiplier > 0; output[--multiplier] = input) {}
        return output.join('');
    }
    var str_format = function() {
        if (!str_format.cache.hasOwnProperty(arguments[0])) {
            str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
        }
        return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
    };
    str_format.format = function(parse_tree, argv) {
        var cursor = 1,
            tree_length = parse_tree.length,
            node_type = '',
            arg, output = [],
            i,
            k,
            match,
            pad,
            pad_character,
            pad_length;
        for (i = 0; i < tree_length; i++) {
            node_type = get_type(parse_tree[i]);
            if (node_type === 'string') {
                output.push(parse_tree[i]);
            } else if (node_type === 'array') {
                match = parse_tree[i];
                if (match[2]) {
                    arg = argv[cursor];
                    for (k = 0; k < match[2].length; k++) {
                        if (!arg.hasOwnProperty(match[2][k])) {
                            throw (sprintf('[sprintf] property "%s" does not exist', match[2][k]));
                        }
                        arg = arg[match[2][k]];
                    }
                } else if (match[1]) {
                    arg = argv[match[1]];
                } else {
                    arg = argv[cursor++];
                }
                if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
                    throw (sprintf('[sprintf] expecting number but found %s', get_type(arg)));
                }
                switch (match[8]) {
                    case 'b':
                        arg = arg.toString(2);
                        break;
                    case 'c':
                        arg = String.fromCharCode(arg);
                        break;
                    case 'd':
                        arg = parseInt(arg, 10);
                        break;
                    case 'e':
                        arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential();
                        break;
                    case 'f':
                        arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg);
                        break;
                    case 'o':
                        arg = arg.toString(8);
                        break;
                    case 's':
                        arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg);
                        break;
                    case 'u':
                        arg = Math.abs(arg);
                        break;
                    case 'x':
                        arg = arg.toString(16);
                        break;
                    case 'X':
                        arg = arg.toString(16).toUpperCase();
                        break;
                }
                arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+' + arg: arg);
                pad_character = match[4] ? match[4] == '0' ? '0': match[4].charAt(1) : ' ';
                pad_length = match[6] - String(arg).length;
                pad = match[6] ? str_repeat(pad_character, pad_length) : '';
                output.push(match[5] ? arg + pad: pad + arg);
            }
        }
        return output.join('');
    };
    str_format.cache = {};
    str_format.parse = function(fmt) {
        var _fmt = fmt,
            match = [],
            parse_tree = [],
            arg_names = 0;
        while (_fmt) {
            if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
                parse_tree.push(match[0]);
            } else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
                parse_tree.push('%');
            } else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
                if (match[2]) {
                    arg_names |= 1;
                    var field_list = [],
                        replacement_field = match[2],
                        field_match = [];
                    if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
                        field_list.push(field_match[1]);
                        while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
                            if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
                                field_list.push(field_match[1]);
                            } else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
                                field_list.push(field_match[1]);
                            } else {
                                throw ('[sprintf] huh?');
                            }
                        }
                    } else {
                        throw ('[sprintf] huh?');
                    }
                    match[2] = field_list;
                } else {
                    arg_names |= 2;
                }
                if (arg_names === 3) {
                    throw ('[sprintf] mixing positional and named placeholders is not (yet) supported');
                }
                parse_tree.push(match);
            } else {
                throw ('[sprintf] huh?');
            }
            _fmt = _fmt.substring(match[0].length);
        }
        return parse_tree;
    };
    return str_format;
})();
var vsprintf = function(fmt, argv) {
    argv.unshift(fmt);
    return sprintf.apply(null, argv);
};
function simpleWizard(ident, header, _height, _back, _ext, _addload) {
    var height = _height || false;
    var ext = _ext || {};
    var addload = _addload ||
        function() {};
    var back = _back ||
        function() {
            window.location.reload();
        };
    $('<div id="winsimplewizard" iconCls="icon-ok" style="width: 620px; padding: 10px 10px 20px 10px;' + (height ? ' height: ' + height + 'px; overflow-y: auto': '') + '" title="' + getTranslation(header) + '"></div>').appendTo('body');
    $('#winsimplewizard').wizard(ident, $.extend({
            load: function() {
                if (typeof($('#winsimplewizard').data('panel')) != 'undefined') $('#winsimplewizard').window('close');
                $('#winsimplewizard').window({
                    modal: true,
                    closed: true,
                    collapsible: false,
                    minimizable: false,
                    maximizable: false,
                    closable: false,
                    top: 50,
                    onClose: function() {}
                });
                addload();
                $('#winsimplewizard').window('open');
                $('#winsimplewizard').window('restore');
            },
            cancel: function() {
                $('#winsimplewizard').window('destroy');
            },
            end: function() {
                loadingHide();
                $('#winsimplewizard').window('destroy');
                back();
            }
        },
        ext));
}
function showDisclamerPhone() {
    var win = $('<div style="width: 620px;"></div>').html('<div style="margin: 10px;"><div style="font-size: 1.7em;">' + getTranslation('start_disclamer_3', {}) + '</div>' + '<a href="#" class="easyui-linkbutton close" iconCls="icon-ok">' + getTranslation('Ok') + '</div>').appendTo('body');
    win.window({
        title: getTranslation('Warning'),
        collapsible: false,
        minimizable: false,
        maximizable: false,
        closable: false,
        iconCls: 'icon-notify',
        onClose: function() {
            $(this).window('destroy');
        }
    });
    $('a.close', win).linkbutton().click(function() {
        win.window('close');
    });
    $('a.do_full', win).click(function() {
        doFullRegPhone(function() {
            win.window('close');
        });
    });
}
function showCommonDisclamer(text, id, opts) {
    id = id || 0;
    opts = opts || {};
    var fontsize = opts.fontsize || '1.7em';
    var width = opts.width || '620px';
    var win = $('<div style="width: ' + width + ';"></div>').html('<div style="margin: 10px;"><div style="font-size: ' + fontsize + '; margin-bottom: 15px;">' + text + '</div>' + '<!--a href="#" class="easyui-linkbutton close" iconCls="icon-ok">' + getTranslation('Ok') + '</a-->' + (id ? '<a href="#" class="easyui-linkbutton noshow" iconCls="icon-cancel">' + getTranslation('dontshow') + '</a>': '') + '</div>').appendTo('body');
    var winopts = {
        title: getTranslation('Warning'),
        collapsible: false,
        minimizable: false,
        maximizable: false,
        closable: true,
        iconCls: 'icon-notify',
        onClose: function() {
            $(this).window('destroy');
        }
    };
    win.window(winopts);
    $('a.close', win).linkbutton().click(function() {
        win.window('close');
        return false;
    });
    $('a.noshow', win).linkbutton().click(function() {
        $.ajax({
            'url': '890.npl?a=kill_disclamer&ident=' + id,
            success: function(data) {
                win.window('close');
            }
        });
        return false;
    });
}
function showDisclamer() {
    var win = $('<div style="width: 620px;"></div>').html('<div style="margin: 10px;"><div style="font-size: 1.7em;">' + getTranslation('start_disclamer_2_{code}', {
        code: $('.draft_users').attr('data-code')
    }) + '</div>' + '<a href="#" class="easyui-linkbutton close" iconCls="icon-ok">' + getTranslation('Ok') + '</div>').appendTo('body');
    win.window({
        title: getTranslation('Warning'),
        collapsible: false,
        minimizable: false,
        maximizable: false,
        closable: false,
        iconCls: 'icon-notify',
        onClose: function() {
            $(this).window('destroy');
        }
    });
    $('a.more', win).click(function() {
        $('div.more', win).slideDown();
        return false;
    });
    $('a.close', win).linkbutton().click(function() {
        $.ajax({
            url: '890.npl',
            data: {
                a: 'start',
                email: $('#email_code').val() || '',
                phone: $('#mobile_code').val() || ''
            },
            success: function(data) {
                window.location.hash = '';
                win.window('close');
            }
        });
    });
}
$(function() {
    DynUsr.init();
    $.ajaxSetup({
        type: 'POST',
        dataType: 'json',
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            loadingHide();
            if (parseInt(XMLHttpRequest.status) == 401) {
                $.messager.alert(getTranslation('Error'), getTranslation('Session timeout'), 'error',
                    function() {
                        window.location.href = '/';
                    })
            } else if (parseInt(XMLHttpRequest.status) == 405) {
                showDraftWindow();
            } else if (parseInt(XMLHttpRequest.status) == 503) {
                showError('server_error_reload_page_and_try_again_later');
            } else if (parseInt(XMLHttpRequest.status) == 434) {
                document.location.href = 'maintenance.html';
            }
        }
    });
    /*    if (user_lang != 'ru') {
            $('.webinar_button').remove();
        }*/
    var pcs = window.location.hash.split('?');
    if (pcs[0] == '#india_message') {
        window.location.hash = '';
    }
    if (pcs[0] == '#es_message') {
        $.ajax({
            url: '1000.npl?a=es_message',
            success: function(data) {
                var r = data.res;
                if (r != '') {
                    showCommonDisclamer(r, 11, {
                        fontsize: '1.1em',
                        width: '1000px'
                    });
                }
                window.location.hash = '';
            }
        });
    }
    if (pcs[0] == '#fgpc_message') {
        $.ajax({
            url: '1000.npl?a=fgpc_message',
            success: function(data) {
                var r = data.res;
                if (r != '') {
                    showCommonDisclamer(r, 11, {
                        fontsize: '1.1em',
                        width: '1000px'
                    });
                }
                window.location.hash = '';
            }
        });
    }
    if (pcs[0] == '#video') {
        showCommonDisclamer('<iframe width="560" height="315" src="https://www.youtube.com/embed/_0x6vXa72Ts" frameborder="0" allowfullscreen></iframe>', 6, {
            width: '590px'
        });
        window.location.hash = '';
    }
    if (typeof(pcs[1]) != 'undefined' && pcs[1] == 'r=1') {
        $.ajax({
            'url': '890.npl?a=kill_disclamer&ident=1',
            success: function(data) {}
        });
    }
    $('[data-hint]').each(function() {
        $(this).bt('<span style="font-size: 14px !important;">' + $(this).attr('data-hint') + '</span>', {
            closeWhenOthersOpen: true,
            width: 400
        });
    });
    $('a[href*="sergey-mavrodi.com"]').each(function() {
        if (!$(this).hasClass('norewrite')) {
            $(this).attr('href', replace_domain($(this).attr('href')));
        }
    });
    $('[data-url*="sergey-mavrodi.com"]').each(function() {
        if (!$(this).hasClass('norewrite')) {
            $(this).attr('data-url', replace_domain($(this).attr('data-url')));
        }
    });
    if (window.location.hash == '#buy') {
        createIn();
    }
    if (window.location.hash == '#show_disclamer') {
        showDisclamer();
    }
    if (window.location.hash == '#show_disclamer_phone') {
        showDisclamerPhone();
    }
    http = /\/\/alex1.loc\/\w{5}\/desktop.html(.*)/;
    http1 = /\/\/10.8.0.158\/\w{5}\/desktop.html(.*)/;
    if (http.test(window.location.href) || http1.test(window.location.href)) {
        $('.desc_wrap').html('');
        $('.desc_wrap').css('box-shadow', '0 0 0 0');
        $('.desc_wrap').css('background', 'none');
        $('.desc_wrap').css('height', '0');
        $('.desc_wrap').css('margin', '0');
    }
    /* if (desktop_theme === 1) $('.panel-body').css("background", "url('img
 /was_painted.png') repeat");*/
    if (! (typeof(lang_vars) == 'undefined')) {
        $.each($('.translate, .l-btn-text, [class*="title"], .menu-text'),
            function(id, value) {
                $(value).html(getTranslation($(value).html()));
            });
        $(document).attr('title', getTranslation($(document).attr('title')));
        $('.easyui-menubutton span.l-btn-text').each(function() {
            $(this).find('span').remove();
            $(this).text(getTranslation($(this).text()));
            $('<span class="m-btn-downarrow">&nbsp;</span>').appendTo($(this));
        });
    }
    $('#my_menu [dataUnread]').each(function() {
        $(this).html($(this).html() + " <span class='unread'>" + $(this).attr('dataUnread') + "</span>");
    });
    $('.subMenuHref[dataUnread]').each(function() {
        $(this).find(".menu-text").html($(this).find(".menu-text").html() + " <span class='unread'>" + $(this).attr('dataUnread') + "</span>");
    });
    $('a[href^="{p:"]').live('click',
        function() {
            var t = $(this).attr('href'.split('{p:'));
            gotoPage(t[0]);
            return false;
        });
    $('.subMenuHref').live('click',
        function() {
            if ($(this).attr('onClick')) {
                return false;
            }
            var away = $(this).attr('data-url') || false;
            if (away) {
                window.open(away);
            } else {
                h1 = window.location.href.split('#');
                h2 = $(this).attr('data-href').split('#');
                h3 = h1[0].split('/');
                window.location.href = $(this).attr('data-href');
                if (h2[0] == h3[h3.length - 1]) {
                    window.location.reload();
                }
            }
        });
    checkNotice();
    createLoadingMessage();
    user_perms={};
    selectedUserId = user_perms.id;
    if (user_perms.id_position == 5) {
        performDraft();
    }
    if (user_perms.id_position == 4) {
        performPhoneDraft();
    }
    if (window.location.hash == '#bay_cash') {
        simpleWizard('cashMavroBuy', 'cashMavroBuy_header', false, false, {});
    }
    if (window.location.hash == '#direct_gift') {
        simpleWizard('wizard_direct_gift', 'wizard_direct_gift_header', false, false, {},
            function() {
                if ($('#wizard_out_request_12').length || $('#wizard_row_winsimplewizard_user_mavro').length) {
                    $('#winsimplewizard').css('height', '500px').css('overflow-y', 'auto');
                } else {
                    $('#winsimplewizard').css('height', 'auto').css('overflow-y', 'inherit');
                }
            });
    }
    if (window.location.hash == '#leave') {
        simpleWizard('wizard_leave_in', 'wizard_leave_in_header');
    }
    if (window.location.hash == '#leave_out') {
        simpleWizard('wizard_leave_out', 'wizard_leave_in_header');
    }
    if (window.location.hash == '#input_debt_after_restart') {
        simpleWizard('input_debt_after_restart', 'input_debt_after_restart_header', false,
            function() {
                window.location = 'desktop.html';
            });
    }
    if (window.location.hash == '#check_activate') {
        simpleWizard('check_activate', 'wizard_check_activate_header');
    }
});
function performPhoneDraft() {
    if (window.location.hash == '#phone_reg') {
        doFullRegPhone();
    }
    $('#do_full_email').click(function() {
        doFullRegPhone();
    });
}
function doFullRegPhone(fn) {
    if (window.location.href.indexOf('desktop.html') + 1) {
        window.location.hash = '';
        var ident = 'complete_phone_registration';
        var header = 'do_full_email';
        var height = false;
        $('<div id="winsimplewizard" iconCls="icon-ok" style="width: 620px; padding: 10px 10px 20px 10px;' + (height ? ' height: ' + height + 'px; overflow-y: auto': '') + '" title="' + getTranslation(header) + '"></div>').appendTo('body');
        $('#winsimplewizard').wizard(ident, {
            load: function() {
                if (typeof($('#winsimplewizard').data('panel')) != 'undefined') $('#winsimplewizard').window('close');
                $('#winsimplewizard').window({
                    modal: true,
                    closed: true,
                    collapsible: false,
                    minimizable: false,
                    maximizable: false,
                    closable: false,
                    top: 50,
                    onClose: function() {}
                });
                $('#winsimplewizard').window('open');
                $('#winsimplewizard').window('restore');
            },
            cancel: function() {
                $('#winsimplewizard').window('destroy');
            },
            advCheck: function(dt, f) {
                $.ajax({
                    url: '890.npl',
                    data: $.extend(dt, {
                        a: 'check_email_only'
                    }),
                    success: function(data) {
                        if (handleState(data)) {
                            f(dt);
                        } else {
                            showError(data[23]);
                        }
                    }
                });
            },
            end: function() {
                loadingHide();
                $('#winsimplewizard').window('destroy');
                if (fn) {
                    fn();
                } else {
                    window.location.reload();
                }
            }
        });
    } else {
        var pices = window.location.href.split('/');
        window.location.href = '/' + pices[3] + '/desktop.html#phone_reg';
    }
}
function delpic(data){
    $("li[c-data-id='"+data+"']").remove();
    $("input[c-data-pic='"+data+"']").remove();
    $("img[c-data-pic='"+data+"']").remove();
}
function doFullReg(fn) {
    if (window.location.href.indexOf('desktop.html') + 1) {
        window.location.hash = '';
        var ident = 'complete_registration';
        var header = 'complete_registration';
        var height = false;
        $('<div id="winsimplewizard" iconCls="icon-ok" style="width: 620px; padding: 10px 10px 20px 10px;' + (height ? ' height: ' + height + 'px; overflow-y: auto': '') + '" title="' + getTranslation(header) + '"></div>').appendTo('body');
        $('#winsimplewizard').wizard(ident, {
            load: function() {
                if (typeof($('#winsimplewizard').data('panel')) != 'undefined') $('#winsimplewizard').window('close');
                $('#winsimplewizard').window({
                    modal: true,
                    closed: true,
                    collapsible: false,
                    minimizable: false,
                    maximizable: false,
                    closable: false,
                    top: 50,
                    onClose: function() {}
                });
                var root = this;
                function showAdv(s) {
                    if (s) {
                        if (!$('#adv_email_phone_disclamer').length) {
                            var d = $('<div id="adv_email_phone_disclamer" style="padding: 3px;">' + getTranslation('fill_email_phone_descr') + '</div>');
                            d.insertBefore('#wizard_row_winsimplewizard_email');
                        }
                    } else {
                        $('#adv_email_phone_disclamer').remove();
                    }
                }
                $('#wizard_field_winsimplewizard_country').combobox({
                    onSelect: function(item) {
                        if ([50, 62].indexOf(parseInt(item.id, 10)) >= 0) {
                            $('input[name="email"]', $(root)).validatebox({
                                required: false
                            }).validatebox('validate');
                            showAdv(true);
                        } else {
                            $('input[name="email"]', $(root)).validatebox({
                                required: true,
                                validType: 'email'
                            });
                            showAdv(false);
                        }
                    },
                    width: 180
                });
                $('input[name="email"]', $(root)).validatebox({
                    required: false
                }).validatebox('validate');
                showAdv(true);
                $('[name="phone"]', $(root)).keyup(function() {
                    var e = /^\+?\d{10,12}$/g;
                    var v = $(this).val();
                    if (!e.test(v)) {
                        v = v.replace(/[^\d]/gi, '');
                        if (v.length > 12) {
                            v = v.substr(0, 12);
                        }
                        $(this).val(v);
                    }
                });
                $('#winsimplewizard').window('open');
                $('#winsimplewizard').window('restore');
            },
            cancel: function() {
                $('#winsimplewizard').window('destroy');
            },
            advCheck: function(dt, f) {
                $.ajax({
                    url: '890.npl',
                    data: $.extend(dt, {
                        a: 'check'
                    }),
                    success: function(data) {
                        if (handleState(data)) {
                            f(dt);
                        } else {
                            showError(data[23]);
                        }
                    }
                });
            },
            end: function() {
                loadingHide();
                $('#winsimplewizard').window('destroy');
                if (fn) {
                    fn();
                } else {
                    window.location.reload();
                }
            }
        });
    } else {
        var pices = window.location.href.split('/');
        window.location.href = '/' + pices[3] + '/desktop.html#reg';
    }
}
function showDraftWindow(fn) {
    var win = $('<div style="width: 300px;"></div>').html('<div style="margin: 10px;">' + getTranslation('you_must_make_full_register') + '</div>').appendTo('body');
    win.window({
        title: getTranslation('Warning'),
        iconCls: 'icon-notify',
        onClose: function() {
            $(this).window('destroy');
        }
    });
    $('a.do', win).click(function() {
        doFullReg(function() {
            win.window('close');
            if (fn) {
                fn();
            }
        });
        return false;
    });
}
function performDraft() {
    if (window.location.hash == '#reg') {
        doFullReg();
    }
    $('#do_full_reg').click(function() {
        doFullReg();
    });
}
function fall(to) {
    $.ajax({
        url: '891.npl',
        data: {
            a: 'fall',
            to: to
        },
        success: function(data) {
            if (handleState(data)) {
                Storage.poolClear();
                window.location.href = data[42].url;
            } else {
                showError(data[23]);
            }
        }
    });
}
function revert() {
    $.ajax({
        url: '891.npl',
        success: function(data) {
            if (handleState(data)) {
                Storage.poolClear();
                window.location.href = data[42].url;
            } else {
                showError(data[23]);
            }
        }
    });
}
function replace_domain(url) {
    var ourdomains = ['sergey-mavrodi.com', 'sergeymavrodi.com', 'sergey-mavrodi-mmm.net', 'sergey-mavrodi-mmm.org', 'sergey-mavrodi.ms'];
    if ($.cookie('from') && ourdomains.indexOf($.cookie('from')) >= 0) {
        return url.replace('sergey-mavrodi.com', $.cookie('from'));
    } else {
        var p = window.location.href.split('/');
        var dom = p[2];
        if (dom != 'mmmoffice.com' && dom != 'mmm-office.com') {
            var site = dom.split('.');
            return url.replace('sergey-mavrodi.com', site[1] + '.' + site[2]);
        } else {
            return url;
        }
    }
}
function var_dump(obj) {
    var out = "";
    if (obj && typeof(obj) == "object") {
        for (var i in obj) {
            out += i + ": " + obj[i] + "\n";
        }
    } else {
        out = obj;
    }
    alert(out);
}
function isUndefined(per) {
    if (typeof per === "undefined") {
        return true;
    } else return false;
} (function($) {
    function img(url) {
        var i = new Image;
        i.src = url;
        return i;
    }
    if ('naturalWidth' in (new Image)) {
        $.fn.naturalWidth = function() {
            return this[0].naturalWidth;
        };
        $.fn.naturalHeight = function() {
            return this[0].naturalHeight;
        };
        return;
    }
    $.fn.naturalWidth = function() {
        return img(this.src).width;
    };
    $.fn.naturalHeight = function() {
        return img(this.src).height;
    };
})(jQuery);
jQuery.bt = {
    version: '0.9.5-rc1'
};; (function($) {
    jQuery.fn.bt = function(content, options) {
        if (typeof content != 'string') {
            var contentSelect = true;
            options = content;
            content = false;
        } else {
            var contentSelect = false;
        }
        if (jQuery.fn.hoverIntent && jQuery.bt.defaults.trigger == 'hover') {
            jQuery.bt.defaults.trigger = 'hoverIntent';
        }
        return this.each(function(index) {
            var opts = jQuery.extend(false, jQuery.bt.defaults, jQuery.bt.options, options);
            opts.spikeLength = numb(opts.spikeLength);
            opts.spikeGirth = numb(opts.spikeGirth);
            opts.overlap = numb(opts.overlap);
            var ajaxTimeout = false;
            if (opts.killTitle) {
                $(this).find('[title]').andSelf().each(function() {
                    if (!$(this).attr('bt-xTitle')) {
                        $(this).attr('bt-xTitle', $(this).attr('title')).attr('title', '');
                    }
                });
            }
            if (typeof opts.trigger == 'string') {
                opts.trigger = [opts.trigger];
            }
            if (opts.trigger[0] == 'hoverIntent') {
                var hoverOpts = jQuery.extend(opts.hoverIntentOpts, {
                    over: function() {
                        this.btOn();
                    },
                    out: function() {
                        this.btOff();
                    }
                });
                $(this).hoverIntent(hoverOpts);
            } else if (opts.trigger[0] == 'hover') {
                $(this).hover(function() {
                        this.btOn();
                    },
                    function() {
                        this.btOff();
                    });
            } else if (opts.trigger[0] == 'now') {
                if ($(this).hasClass('bt-active')) {
                    this.btOff();
                } else {
                    this.btOn();
                }
            } else if (opts.trigger[0] == 'none') {} else if (opts.trigger.length > 1 && opts.trigger[0] != opts.trigger[1]) {
                $(this).bind(opts.trigger[0],
                    function() {
                        this.btOn();
                    }).bind(opts.trigger[1],
                    function() {
                        this.btOff();
                    });
            } else {
                $(this).bind(opts.trigger[0],
                    function() {
                        if ($(this).hasClass('bt-active')) {
                            this.btOff();
                        } else {
                            this.btOn();
                        }
                    });
            }
            this.btOn = function() {
                if (typeof $(this).data('bt-box') == 'object') {
                    this.btOff();
                }
                opts.preBuild.apply(this);
                $(jQuery.bt.vars.closeWhenOpenStack).btOff();
                $(this).addClass('bt-active ' + opts.activeClass);
                if (contentSelect && opts.ajaxPath == null) {
                    if (opts.killTitle) {
                        $(this).attr('title', $(this).attr('bt-xTitle'));
                    }
                    content = $.isFunction(opts.contentSelector) ? opts.contentSelector.apply(this) : eval(opts.contentSelector);
                    if (opts.killTitle) {
                        $(this).attr('title', '');
                    }
                }
                if (opts.ajaxPath != null && content == false) {
                    if (typeof opts.ajaxPath == 'object') {
                        var url = eval(opts.ajaxPath[0]);
                        url += opts.ajaxPath[1] ? ' ' + opts.ajaxPath[1] : '';
                    } else {
                        var url = opts.ajaxPath;
                    }
                    var off = url.indexOf(" ");
                    if (off >= 0) {
                        var selector = url.slice(off, url.length);
                        url = url.slice(0, off);
                    }
                    var cacheData = opts.ajaxCache ? $(document.body).data('btCache-' + url.replace(/\./g, '')) : null;
                    if (typeof cacheData == 'string') {
                        content = selector ? $("<div/>").append(cacheData.replace(/<script(.|\s)*?\/script>/g, "")).find(selector) : cacheData;
                    } else {
                        var target = this;
                        var ajaxOpts = jQuery.extend(false, {
                                type: opts.ajaxType,
                                data: opts.ajaxData,
                                cache: opts.ajaxCache,
                                url: url,
                                complete: function(XMLHttpRequest, textStatus) {
                                    if (textStatus == 'success' || textStatus == 'notmodified') {
                                        if (opts.ajaxCache) {
                                            $(document.body).data('btCache-' + url.replace(/\./g, ''), XMLHttpRequest.responseText);
                                        }
                                        ajaxTimeout = false;
                                        content = selector ? $("<div/>").append(XMLHttpRequest.responseText.replace(/<script(.|\s)*?\/script>/g, "")).find(selector) : XMLHttpRequest.responseText;
                                    } else {
                                        if (textStatus == 'timeout') {
                                            ajaxTimeout = true;
                                        }
                                        content = opts.ajaxError.replace(/%error/g, XMLHttpRequest.statusText);
                                    }
                                    if ($(target).hasClass('bt-active')) {
                                        target.btOn();
                                    }
                                }
                            },
                            opts.ajaxOpts);
                        jQuery.ajax(ajaxOpts);
                        content = opts.ajaxLoading;
                    }
                }
                var shadowMarginX = 0;
                var shadowMarginY = 0;
                var shadowShiftX = 0;
                var shadowShiftY = 0;
                if (opts.shadow && !shadowSupport()) {
                    opts.shadow = false;
                    jQuery.extend(opts, opts.noShadowOpts);
                }
                if (opts.shadow) {
                    if (opts.shadowBlur > Math.abs(opts.shadowOffsetX)) {
                        shadowMarginX = opts.shadowBlur * 2;
                    } else {
                        shadowMarginX = opts.shadowBlur + Math.abs(opts.shadowOffsetX);
                    }
                    shadowShiftX = (opts.shadowBlur - opts.shadowOffsetX) > 0 ? opts.shadowBlur - opts.shadowOffsetX: 0;
                    if (opts.shadowBlur > Math.abs(opts.shadowOffsetY)) {
                        shadowMarginY = opts.shadowBlur * 2;
                    } else {
                        shadowMarginY = opts.shadowBlur + Math.abs(opts.shadowOffsetY);
                    }
                    shadowShiftY = (opts.shadowBlur - opts.shadowOffsetY) > 0 ? opts.shadowBlur - opts.shadowOffsetY: 0;
                }
                if (opts.offsetParent) {
                    var offsetParent = $(opts.offsetParent);
                    var offsetParentPos = offsetParent.offset();
                    var pos = $(this).offset();
                    var top = numb(pos.top) - numb(offsetParentPos.top) + numb($(this).css('margin-top')) - shadowShiftY;
                    var left = numb(pos.left) - numb(offsetParentPos.left) + numb($(this).css('margin-left')) - shadowShiftX;
                } else {
                    var offsetParent = ($(this).css('position') == 'absolute') ? $(this).parents().eq(0).offsetParent() : $(this).offsetParent();
                    var pos = $(this).btPosition();
                    var top = numb(pos.top) + numb($(this).css('margin-top')) - shadowShiftY;
                    var left = numb(pos.left) + numb($(this).css('margin-left')) - shadowShiftX;
                }
                var width = $(this).btOuterWidth();
                var height = $(this).outerHeight();
                if (typeof content == 'object') {
                    var original = content;
                    var clone = $(original).clone(true).show();
                    var origClones = $(original).data('bt-clones') || [];
                    origClones.push(clone);
                    $(original).data('bt-clones', origClones);
                    $(clone).data('bt-orig', original);
                    $(this).data('bt-content-orig', {
                        original: original,
                        clone: clone
                    });
                    content = clone;
                }
                if (typeof content == 'null' || content == '') {
                    return;
                }
                var $text = $('<div class="bt-content"></div>').append(content).css({
                    padding: opts.padding,
                    position: 'absolute',
                    width: (opts.shrinkToFit ? 'auto': opts.width),
                    zIndex: opts.textzIndex,
                    left: shadowShiftX,
                    top: shadowShiftY
                }).css(opts.cssStyles);
                var $box = $('<div class="bt-wrapper"></div>').append($text).addClass(opts.cssClass).css({
                    position: 'absolute',
                    width: opts.width,
                    zIndex: opts.wrapperzIndex,
                    visibility: 'hidden'
                }).appendTo(offsetParent);
                if (jQuery.fn.bgiframe) {
                    $text.bgiframe();
                    $box.bgiframe();
                }
                $(this).data('bt-box', $box);
                var scrollTop = numb($(document).scrollTop());
                var scrollLeft = numb($(document).scrollLeft());
                var docWidth = numb($(window).width());
                var docHeight = numb($(window).height());
                var winRight = scrollLeft + docWidth;
                var winBottom = scrollTop + docHeight;
                var space = new Object();
                var thisOffset = $(this).offset();
                space.top = thisOffset.top - scrollTop;
                space.bottom = docHeight - ((thisOffset + height) - scrollTop);
                space.left = thisOffset.left - scrollLeft;
                space.right = docWidth - ((thisOffset.left + width) - scrollLeft);
                var textOutHeight = numb($text.outerHeight());
                var textOutWidth = numb($text.btOuterWidth());
                if (opts.positions.constructor == String) {
                    opts.positions = opts.positions.replace(/ /, '').split(',');
                }
                if (opts.positions[0] == 'most') {
                    var position = 'top';
                    for (var pig in space) {
                        position = space[pig] > space[position] ? pig: position;
                    }
                } else {
                    for (var x in opts.positions) {
                        var position = opts.positions[x];
                        if ((position == 'left' || position == 'right') && space[position] > textOutWidth + opts.spikeLength) {
                            break;
                        } else if ((position == 'top' || position == 'bottom') && space[position] > textOutHeight + opts.spikeLength) {
                            break;
                        }
                    }
                }
                var horiz = left + ((width - textOutWidth) * .5);
                var vert = top + ((height - textOutHeight) * .5);
                var points = new Array();
                var textTop, textLeft, textRight, textBottom, textTopSpace, textBottomSpace, textLeftSpace, textRightSpace, crossPoint, textCenter, spikePoint;
                switch (position) {
                    case 'top':
                        $text.css('margin-bottom', opts.spikeLength + 'px');
                        $box.css({
                            top: (top - $text.outerHeight(true)) + opts.overlap,
                            left: horiz
                        });
                        textRightSpace = (winRight - opts.windowMargin) - ($text.offset().left + $text.btOuterWidth(true));
                        var xShift = shadowShiftX;
                        if (textRightSpace < 0) {
                            $box.css('left', (numb($box.css('left')) + textRightSpace) + 'px');
                            xShift -= textRightSpace;
                        }
                        textLeftSpace = ($text.offset().left + numb($text.css('margin-left'))) - (scrollLeft + opts.windowMargin);
                        if (textLeftSpace < 0) {
                            $box.css('left', (numb($box.css('left')) - textLeftSpace) + 'px');
                            xShift += textLeftSpace;
                        }
                        textTop = $text.btPosition().top + numb($text.css('margin-top'));
                        textLeft = $text.btPosition().left + numb($text.css('margin-left'));
                        textRight = textLeft + $text.btOuterWidth();
                        textBottom = textTop + $text.outerHeight();
                        textCenter = {
                            x: textLeft + ($text.btOuterWidth() * opts.centerPointX),
                            y: textTop + ($text.outerHeight() * opts.centerPointY)
                        };
                        points[points.length] = spikePoint = {
                            y: textBottom + opts.spikeLength,
                            x: ((textRight - textLeft) * .5) + xShift,
                            type: 'spike'
                        };
                        crossPoint = findIntersectX(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textBottom);
                        crossPoint.x = crossPoint.x < textLeft + opts.spikeGirth / 2 + opts.cornerRadius ? textLeft + opts.spikeGirth / 2 + opts.cornerRadius: crossPoint.x;
                        crossPoint.x = crossPoint.x > (textRight - opts.spikeGirth / 2) - opts.cornerRadius ? (textRight - opts.spikeGirth / 2) - opts.CornerRadius: crossPoint.x;
                        points[points.length] = {
                            x: crossPoint.x - (opts.spikeGirth / 2),
                            y: textBottom,
                            type: 'join'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: textBottom,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: textTop,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: textTop,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: textBottom,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: crossPoint.x + (opts.spikeGirth / 2),
                            y: textBottom,
                            type: 'join'
                        };
                        points[points.length] = spikePoint;
                        break;
                    case 'left':
                        $text.css('margin-right', opts.spikeLength + 'px');
                        $box.css({
                            top: vert + 'px',
                            left: ((left - $text.btOuterWidth(true)) + opts.overlap) + 'px'
                        });
                        textBottomSpace = (winBottom - opts.windowMargin) - ($text.offset().top + $text.outerHeight(true));
                        var yShift = shadowShiftY;
                        if (textBottomSpace < 0) {
                            $box.css('top', (numb($box.css('top')) + textBottomSpace) + 'px');
                            yShift -= textBottomSpace;
                        }
                        textTopSpace = ($text.offset().top + numb($text.css('margin-top'))) - (scrollTop + opts.windowMargin);
                        if (textTopSpace < 0) {
                            $box.css('top', (numb($box.css('top')) - textTopSpace) + 'px');
                            yShift += textTopSpace;
                        }
                        textTop = $text.btPosition().top + numb($text.css('margin-top'));
                        textLeft = $text.btPosition().left + numb($text.css('margin-left'));
                        textRight = textLeft + $text.btOuterWidth();
                        textBottom = textTop + $text.outerHeight();
                        textCenter = {
                            x: textLeft + ($text.btOuterWidth() * opts.centerPointX),
                            y: textTop + ($text.outerHeight() * opts.centerPointY)
                        };
                        points[points.length] = spikePoint = {
                            x: textRight + opts.spikeLength,
                            y: ((textBottom - textTop) * .5) + yShift,
                            type: 'spike'
                        };
                        crossPoint = findIntersectY(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textRight);
                        crossPoint.y = crossPoint.y < textTop + opts.spikeGirth / 2 + opts.cornerRadius ? textTop + opts.spikeGirth / 2 + opts.cornerRadius: crossPoint.y;
                        crossPoint.y = crossPoint.y > (textBottom - opts.spikeGirth / 2) - opts.cornerRadius ? (textBottom - opts.spikeGirth / 2) - opts.cornerRadius: crossPoint.y;
                        points[points.length] = {
                            x: textRight,
                            y: crossPoint.y + opts.spikeGirth / 2,
                            type: 'join'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: textBottom,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: textBottom,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: textTop,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: textTop,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: crossPoint.y - opts.spikeGirth / 2,
                            type: 'join'
                        };
                        points[points.length] = spikePoint;
                        break;
                    case 'bottom':
                        $text.css('margin-top', opts.spikeLength + 'px');
                        $box.css({
                            top: (top + height) - opts.overlap,
                            left: horiz
                        });
                        textRightSpace = (winRight - opts.windowMargin) - ($text.offset().left + $text.btOuterWidth(true));
                        var xShift = shadowShiftX;
                        if (textRightSpace < 0) {
                            $box.css('left', (numb($box.css('left')) + textRightSpace) + 'px');
                            xShift -= textRightSpace;
                        }
                        textLeftSpace = ($text.offset().left + numb($text.css('margin-left'))) - (scrollLeft + opts.windowMargin);
                        if (textLeftSpace < 0) {
                            $box.css('left', (numb($box.css('left')) - textLeftSpace) + 'px');
                            xShift += textLeftSpace;
                        }
                        textTop = $text.btPosition().top + numb($text.css('margin-top'));
                        textLeft = $text.btPosition().left + numb($text.css('margin-left'));
                        textRight = textLeft + $text.btOuterWidth();
                        textBottom = textTop + $text.outerHeight();
                        textCenter = {
                            x: textLeft + ($text.btOuterWidth() * opts.centerPointX),
                            y: textTop + ($text.outerHeight() * opts.centerPointY)
                        };
                        points[points.length] = spikePoint = {
                            x: ((textRight - textLeft) * .5) + xShift,
                            y: shadowShiftY,
                            type: 'spike'
                        };
                        crossPoint = findIntersectX(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textTop);
                        crossPoint.x = crossPoint.x < textLeft + opts.spikeGirth / 2 + opts.cornerRadius ? textLeft + opts.spikeGirth / 2 + opts.cornerRadius: crossPoint.x;
                        crossPoint.x = crossPoint.x > (textRight - opts.spikeGirth / 2) - opts.cornerRadius ? (textRight - opts.spikeGirth / 2) - opts.cornerRadius: crossPoint.x;
                        points[points.length] = {
                            x: crossPoint.x + opts.spikeGirth / 2,
                            y: textTop,
                            type: 'join'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: textTop,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: textBottom,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: textBottom,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: textTop,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: crossPoint.x - (opts.spikeGirth / 2),
                            y: textTop,
                            type: 'join'
                        };
                        points[points.length] = spikePoint;
                        break;
                    case 'right':
                        $text.css('margin-left', (opts.spikeLength + 'px'));
                        $box.css({
                            top: vert + 'px',
                            left: ((left + width) - opts.overlap) + 'px'
                        });
                        textBottomSpace = (winBottom - opts.windowMargin) - ($text.offset().top + $text.outerHeight(true));
                        var yShift = shadowShiftY;
                        if (textBottomSpace < 0) {
                            $box.css('top', (numb($box.css('top')) + textBottomSpace) + 'px');
                            yShift -= textBottomSpace;
                        }
                        textTopSpace = ($text.offset().top + numb($text.css('margin-top'))) - (scrollTop + opts.windowMargin);
                        if (textTopSpace < 0) {
                            $box.css('top', (numb($box.css('top')) - textTopSpace) + 'px');
                            yShift += textTopSpace;
                        }
                        textTop = $text.btPosition().top + numb($text.css('margin-top'));
                        textLeft = $text.btPosition().left + numb($text.css('margin-left'));
                        textRight = textLeft + $text.btOuterWidth();
                        textBottom = textTop + $text.outerHeight();
                        textCenter = {
                            x: textLeft + ($text.btOuterWidth() * opts.centerPointX),
                            y: textTop + ($text.outerHeight() * opts.centerPointY)
                        };
                        points[points.length] = spikePoint = {
                            x: shadowShiftX,
                            y: ((textBottom - textTop) * .5) + yShift,
                            type: 'spike'
                        };
                        crossPoint = findIntersectY(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textLeft);
                        crossPoint.y = crossPoint.y < textTop + opts.spikeGirth / 2 + opts.cornerRadius ? textTop + opts.spikeGirth / 2 + opts.cornerRadius: crossPoint.y;
                        crossPoint.y = crossPoint.y > (textBottom - opts.spikeGirth / 2) - opts.cornerRadius ? (textBottom - opts.spikeGirth / 2) - opts.cornerRadius: crossPoint.y;
                        points[points.length] = {
                            x: textLeft,
                            y: crossPoint.y - opts.spikeGirth / 2,
                            type: 'join'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: textTop,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: textTop,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textRight,
                            y: textBottom,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: textBottom,
                            type: 'corner'
                        };
                        points[points.length] = {
                            x: textLeft,
                            y: crossPoint.y + opts.spikeGirth / 2,
                            type: 'join'
                        };
                        points[points.length] = spikePoint;
                        break;
                }
                var canvas = document.createElement('canvas');
                $(canvas).attr('width', (numb($text.btOuterWidth(true)) + opts.strokeWidth * 2 + shadowMarginX)).attr('height', (numb($text.outerHeight(true)) + opts.strokeWidth * 2 + shadowMarginY)).appendTo($box).css({
                    position: 'absolute',
                    zIndex: opts.boxzIndex
                });
                if (typeof G_vmlCanvasManager != 'undefined') {
                    canvas = G_vmlCanvasManager.initElement(canvas);
                }
                if (opts.cornerRadius > 0) {
                    var newPoints = new Array();
                    var newPoint;
                    for (var i = 0; i < points.length; i++) {
                        if (points[i].type == 'corner') {
                            newPoint = betweenPoint(points[i], points[(i - 1) % points.length], opts.cornerRadius);
                            newPoint.type = 'arcStart';
                            newPoints[newPoints.length] = newPoint;
                            newPoints[newPoints.length] = points[i];
                            newPoint = betweenPoint(points[i], points[(i + 1) % points.length], opts.cornerRadius);
                            newPoint.type = 'arcEnd';
                            newPoints[newPoints.length] = newPoint;
                        } else {
                            newPoints[newPoints.length] = points[i];
                        }
                    }
                    points = newPoints;
                }
                var ctx = canvas.getContext("2d");
                if (opts.shadow && opts.shadowOverlap !== true) {
                    var shadowOverlap = numb(opts.shadowOverlap);
                    switch (position) {
                        case 'top':
                            if (opts.shadowOffsetX + opts.shadowBlur - shadowOverlap > 0) {
                                $box.css('top', (numb($box.css('top')) - (opts.shadowOffsetX + opts.shadowBlur - shadowOverlap)));
                            }
                            break;
                        case 'right':
                            if (shadowShiftX - shadowOverlap > 0) {
                                $box.css('left', (numb($box.css('left')) + shadowShiftX - shadowOverlap));
                            }
                            break;
                        case 'bottom':
                            if (shadowShiftY - shadowOverlap > 0) {
                                $box.css('top', (numb($box.css('top')) + shadowShiftY - shadowOverlap));
                            }
                            break;
                        case 'left':
                            if (opts.shadowOffsetY + opts.shadowBlur - shadowOverlap > 0) {
                                $box.css('left', (numb($box.css('left')) - (opts.shadowOffsetY + opts.shadowBlur - shadowOverlap)));
                            }
                            break;
                    }
                }
                drawIt.apply(ctx, [points], opts.strokeWidth);
                ctx.fillStyle = opts.fill;
                if (opts.shadow) {
                    ctx.shadowOffsetX = opts.shadowOffsetX;
                    ctx.shadowOffsetY = opts.shadowOffsetY;
                    ctx.shadowBlur = opts.shadowBlur;
                    ctx.shadowColor = opts.shadowColor;
                }
                ctx.closePath();
                ctx.fill();
                if (opts.strokeWidth > 0) {
                    ctx.shadowColor = 'rgba(0, 0, 0, 0)';
                    ctx.lineWidth = opts.strokeWidth;
                    ctx.strokeStyle = opts.strokeStyle;
                    ctx.beginPath();
                    drawIt.apply(ctx, [points], opts.strokeWidth);
                    ctx.closePath();
                    ctx.stroke();
                }
                opts.preShow.apply(this, [$box[0]]);
                $box.css({
                    display: 'none',
                    visibility: 'visible'
                });
                opts.showTip.apply(this, [$box[0]]);
                if (opts.overlay) {
                    var overlay = $('<div class="bt-overlay"></div>').css({
                        position: 'absolute',
                        backgroundColor: 'blue',
                        top: top,
                        left: left,
                        width: width,
                        height: height,
                        opacity: '.2'
                    }).appendTo(offsetParent);
                    $(this).data('overlay', overlay);
                }
                if ((opts.ajaxPath != null && opts.ajaxCache == false) || ajaxTimeout) {
                    content = false;
                }
                if (opts.clickAnywhereToClose) {
                    jQuery.bt.vars.clickAnywhereStack.push(this);
                    $(document).click(jQuery.bt.docClick);
                }
                if (opts.closeWhenOthersOpen) {
                    jQuery.bt.vars.closeWhenOpenStack.push(this);
                }
                opts.postShow.apply(this, [$box[0]]);
            };
            this.btOff = function() {
                var box = $(this).data('bt-box');
                opts.preHide.apply(this, [box]);
                var i = this;
                i.btCleanup = function() {
                    var box = $(i).data('bt-box');
                    var contentOrig = $(i).data('bt-content-orig');
                    var overlay = $(i).data('bt-overlay');
                    if (typeof box == 'object') {
                        $(box).remove();
                        $(i).removeData('bt-box');
                    }
                    if (typeof contentOrig == 'object') {
                        var clones = $(contentOrig.original).data('bt-clones');
                        $(contentOrig).data('bt-clones', arrayRemove(clones, contentOrig.clone));
                    }
                    if (typeof overlay == 'object') {
                        $(overlay).remove();
                        $(i).removeData('bt-overlay');
                    }
                    jQuery.bt.vars.clickAnywhereStack = arrayRemove(jQuery.bt.vars.clickAnywhereStack, i);
                    jQuery.bt.vars.closeWhenOpenStack = arrayRemove(jQuery.bt.vars.closeWhenOpenStack, i);
                    $(i).removeClass('bt-active ' + opts.activeClass);
                    opts.postHide.apply(i);
                }
                opts.hideTip.apply(this, [box, i.btCleanup]);
            };
            var refresh = this.btRefresh = function() {
                this.btOff();
                this.btOn();
            };
        });
        function drawIt(points, strokeWidth) {
            this.moveTo(points[0].x, points[0].y);
            for (i = 1; i < points.length; i++) {
                if (points[i - 1].type == 'arcStart') {
                    this.quadraticCurveTo(round5(points[i].x, strokeWidth), round5(points[i].y, strokeWidth), round5(points[(i + 1) % points.length].x, strokeWidth), round5(points[(i + 1) % points.length].y, strokeWidth));
                    i++;
                } else {
                    this.lineTo(round5(points[i].x, strokeWidth), round5(points[i].y, strokeWidth));
                }
            }
        };
        function round5(num, strokeWidth) {
            var ret;
            strokeWidth = numb(strokeWidth);
            if (strokeWidth % 2) {
                ret = num;
            } else {
                ret = Math.round(num - .5) + .5;
            }
            return ret;
        };
        function numb(num) {
            return parseInt(num) || 0;
        };
        function arrayRemove(arr, elem) {
            var x, newArr = new Array();
            for (x in arr) {
                if (arr[x] != elem) {
                    newArr.push(arr[x]);
                }
            }
            return newArr;
        };
        function canvasSupport() {
            var canvas_compatible = false;
            try {
                canvas_compatible = !!(document.createElement('canvas').getContext('2d'));
            } catch(e) {
                canvas_compatible = !!(document.createElement('canvas').getContext);
            }
            return canvas_compatible;
        }
        function shadowSupport() {
            try {
                var userAgent = navigator.userAgent.toLowerCase();
                if (/webkit/.test(userAgent)) {
                    return true;
                } else if (/gecko|mozilla/.test(userAgent) && parseFloat(userAgent.match(/firefox\/(\d+(?:\.\d+)+)/)[1]) >= 3.1) {
                    return true;
                }
            } catch(err) {}
            return false;
        }
        function betweenPoint(point1, point2, dist) {
            var y, x;
            if (point1.x == point2.x) {
                y = point1.y < point2.y ? point1.y + dist: point1.y - dist;
                return {
                    x: point1.x,
                    y: y
                };
            } else if (point1.y == point2.y) {
                x = point1.x < point2.x ? point1.x + dist: point1.x - dist;
                return {
                    x: x,
                    y: point1.y
                };
            }
        };
        function centerPoint(arcStart, corner, arcEnd) {
            var x = corner.x == arcStart.x ? arcEnd.x: arcStart.x;
            var y = corner.y == arcStart.y ? arcEnd.y: arcStart.y;
            var startAngle, endAngle;
            if (arcStart.x < arcEnd.x) {
                if (arcStart.y > arcEnd.y) {
                    startAngle = (Math.PI / 180) * 180;
                    endAngle = (Math.PI / 180) * 90;
                } else {
                    startAngle = (Math.PI / 180) * 90;
                    endAngle = 0;
                }
            } else {
                if (arcStart.y > arcEnd.y) {
                    startAngle = (Math.PI / 180) * 270;
                    endAngle = (Math.PI / 180) * 180;
                } else {
                    startAngle = 0;
                    endAngle = (Math.PI / 180) * 270;
                }
            }
            return {
                x: x,
                y: y,
                type: 'center',
                startAngle: startAngle,
                endAngle: endAngle
            };
        };
        function findIntersect(r1x1, r1y1, r1x2, r1y2, r2x1, r2y1, r2x2, r2y2) {
            if (r2x1 == r2x2) {
                return findIntersectY(r1x1, r1y1, r1x2, r1y2, r2x1);
            }
            if (r2y1 == r2y2) {
                return findIntersectX(r1x1, r1y1, r1x2, r1y2, r2y1);
            }
            var r1m = (r1y1 - r1y2) / (r1x1 - r1x2);
            var r1b = r1y1 - (r1m * r1x1);
            var r2m = (r2y1 - r2y2) / (r2x1 - r2x2);
            var r2b = r2y1 - (r2m * r2x1);
            var x = (r2b - r1b) / (r1m - r2m);
            var y = r1m * x + r1b;
            return {
                x: x,
                y: y
            };
        };
        function findIntersectY(r1x1, r1y1, r1x2, r1y2, x) {
            if (r1y1 == r1y2) {
                return {
                    x: x,
                    y: r1y1
                };
            }
            var r1m = (r1y1 - r1y2) / (r1x1 - r1x2);
            var r1b = r1y1 - (r1m * r1x1);
            var y = r1m * x + r1b;
            return {
                x: x,
                y: y
            };
        };
        function findIntersectX(r1x1, r1y1, r1x2, r1y2, y) {
            if (r1x1 == r1x2) {
                return {
                    x: r1x1,
                    y: y
                };
            }
            var r1m = (r1y1 - r1y2) / (r1x1 - r1x2);
            var r1b = r1y1 - (r1m * r1x1);
            var x = (y - r1b) / r1m;
            return {
                x: x,
                y: y
            };
        };
    };
    jQuery.fn.btPosition = function() {
        function num(elem, prop) {
            return elem[0] && parseInt(jQuery.curCSS(elem[0], prop, true), 10) || 0;
        };
        var left = 0,
            top = 0,
            results;
        if (this[0]) {
            var offsetParent = this.offsetParent(),
                offset = this.offset(),
                parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? {
                    top: 0,
                    left: 0
                }: offsetParent.offset();
            offset.top -= num(this, 'marginTop');
            offset.left -= num(this, 'marginLeft');
            parentOffset.top += num(offsetParent, 'borderTopWidth');
            parentOffset.left += num(offsetParent, 'borderLeftWidth');
            results = {
                top: offset.top - parentOffset.top,
                left: offset.left - parentOffset.left
            };
        }
        return results;
    };
    jQuery.fn.btOuterWidth = function(margin) {
        function num(elem, prop) {
            return elem[0] && parseInt(jQuery.curCSS(elem[0], prop, true), 10) || 0;
        };
        return this["innerWidth"]() + num(this, "borderLeftWidth") + num(this, "borderRightWidth") + (margin ? num(this, "marginLeft") + num(this, "marginRight") : 0);
    };
    jQuery.fn.btOn = function() {
        return this.each(function(index) {
            if (jQuery.isFunction(this.btOn)) {
                this.btOn();
            }
        });
    };
    jQuery.fn.btOff = function() {
        return this.each(function(index) {
            if (jQuery.isFunction(this.btOff)) {
                this.btOff();
            }
        });
    };
    jQuery.bt.vars = {
        clickAnywhereStack: [],
        closeWhenOpenStack: []
    };
    jQuery.bt.docClick = function(e) {
        if (!e) {
            var e = window.event;
        };
        if (!$(e.target).parents().andSelf().filter('.bt-wrapper, .bt-active').length && jQuery.bt.vars.clickAnywhereStack.length) {
            $(jQuery.bt.vars.clickAnywhereStack).btOff();
            $(document).unbind('click', jQuery.bt.docClick);
        }
    };
    jQuery.bt.defaults = {
        trigger: 'hover',
        clickAnywhereToClose: true,
        closeWhenOthersOpen: false,
        shrinkToFit: false,
        width: '200px',
        padding: '10px',
        spikeGirth: 10,
        spikeLength: 15,
        overlap: 0,
        overlay: false,
        killTitle: true,
        textzIndex: 9999,
        boxzIndex: 9998,
        wrapperzIndex: 9997,
        offsetParent: null,
        positions: ['most'],
        fill: "rgb(255, 255, 102)",
        windowMargin: 10,
        strokeWidth: 1,
        strokeStyle: "#000",
        cornerRadius: 5,
        centerPointX: .5,
        centerPointY: .5,
        shadow: false,
        shadowOffsetX: 2,
        shadowOffsetY: 2,
        shadowBlur: 3,
        shadowColor: "#000",
        shadowOverlap: false,
        noShadowOpts: {
            strokeStyle: '#999'
        },
        cssClass: '',
        cssStyles: {},
        activeClass: 'bt-active',
        contentSelector: "$(this).attr('title')",
        ajaxPath: null,
        ajaxError: '<strong>ERROR:</strong> <em>%error</em>',
        ajaxLoading: '<blink>Loading...</blink>',
        ajaxData: {},
        ajaxType: 'GET',
        ajaxCache: true,
        ajaxOpts: {},
        preBuild: function() {},
        preShow: function(box) {},
        showTip: function(box) {
            $(box).show();
        },
        postShow: function(box) {},
        preHide: function(box) {},
        hideTip: function(box, callback) {
            $(box).hide();
            callback();
        },
        postHide: function() {},
        hoverIntentOpts: {
            interval: 300,
            timeout: 500
        }
    };
    jQuery.bt.options = {};
})(jQuery);
